package com.example.mysql.bizz.impl;

import com.example.mysql.bizz.ILogOperate;
import com.example.mysql.mapper.AsyncLogMapper;
import com.example.mysql.entity.AsyncLog;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;


@Slf4j
@Service
public class LogOperateBizzImpl implements ILogOperate {
    @Autowired
    private AsyncLogMapper asyncLogMapper;

    @Transactional
    @Override
    public AsyncLog addLog(AsyncLog asyncLog) {
        if (StringUtils.isEmpty(asyncLog)) {
            return new AsyncLog();
        }
        int insert = asyncLogMapper.insert(asyncLog);
        if (insert > 0) {
            return asyncLog;
        }
        return null;
    }
}
